//
//  OEOrderDataController.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/8.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEOrderDataController.h"

@implementation OEOrderDataController
+ (void)sendCancleOrderRequestWithOrder_id:(NSString *)order_id handle:(OEOrderDataNormalHandle)handle{
    NSMutableDictionary * paramDic = [NSMutableDictionary new];
    NSString * token = STUserManger.defult.loginedUser.token;
    if (token.length) {
        [paramDic setObject:token forKey:@"user_token"];
    }
    if (order_id.length) {
        [paramDic setObject:order_id forKey:@"order_id"];
    }
    [paramDic setObject:NSBundle.st_UUID forKey:@"unique_id"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php?m=Front&c=User&a=orderCancel"];
    DDLogInfo(@"url:%@",url);
    DDLogInfo(@"param:%@",paramDic);
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:paramDic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 NSDictionary * modelDic = [responseObject valueForKey:@"content"];
                                                 if (handle) {
                                                     handle(YES,@"",modelDic);
                                                 }
                                                 // DDLogInfo(@"json = \n%@",modelDic.mj_JSONString);
                                                 DDLogInfo(@"%@请求成功:resp\n%@",url,responseObject);
                                                 
                                                 
                                             } failure:^(NSString *stateCode, STError *error,NSError *originError) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 if (handle) {
                                                     handle(YES,@"",nil);
                                                 }
                                                 DDLogError(@"\n请求失败:\nurl:%@\nparam:%@\n失败原因:%@\n错误码:%ld",
                                                            url,paramDic,error.desc,error.code);
                                             }];
}
//删除订单
+ (void)sendDeleteOrderRequestWithOrder_id:(NSString*)order_id  handle:(OEOrderDataNormalHandle)handle{
    NSMutableDictionary * paramDic = [NSMutableDictionary new];
    NSString * token = STUserManger.defult.loginedUser.token;
    if (token.length) {
        [paramDic setObject:token forKey:@"user_token"];
    }
    if (order_id.length) {
        [paramDic setObject:order_id forKey:@"order_id"];
    }
    [paramDic setObject:NSBundle.st_UUID forKey:@"unique_id"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php?m=Front&c=User&a=orderDel"];
    DDLogInfo(@"url:%@",url);
    DDLogInfo(@"param:%@",paramDic);
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:paramDic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 NSDictionary * modelDic = [responseObject valueForKey:@"content"];
                                                 if (handle) {
                                                     handle(YES,@"",modelDic);
                                                 }
                                                 // DDLogInfo(@"json = \n%@",modelDic.mj_JSONString);
                                                 DDLogInfo(@"%@请求成功:resp\n%@",url,responseObject);
                                                 
                                                 
                                             } failure:^(NSString *stateCode, STError *error,NSError *originError) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 if (handle) {
                                                     handle(YES,@"",nil);
                                                 }
                                                 DDLogError(@"\n请求失败:\nurl:%@\nparam:%@\n失败原因:%@\n错误码:%ld",
                                                            url,paramDic,error.desc,error.code);
                                             }];
}
//归还订单
+ (void)sendReturnOrderRequestWithOrder_id:(NSString*)order_id  handle:(OEOrderDataNormalHandle)handle{
    NSMutableDictionary * paramDic = [NSMutableDictionary new];
    NSString * token = STUserManger.defult.loginedUser.token;
    if (token.length) {
        [paramDic setObject:token forKey:@"user_token"];
    }
    if (order_id.length) {
        [paramDic setObject:order_id forKey:@"order_id"];
    }
    [paramDic setObject:NSBundle.st_UUID forKey:@"unique_id"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php?m=Front&c=User&a=orderReturn"];
    DDLogInfo(@"url:%@",url);
    DDLogInfo(@"param:%@",paramDic);
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:paramDic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 NSDictionary * modelDic = [responseObject valueForKey:@"content"];
                                                 if (handle) {
                                                     handle(YES,@"",modelDic);
                                                 }
                                                 // DDLogInfo(@"json = \n%@",modelDic.mj_JSONString);
                                                 DDLogInfo(@"%@请求成功:resp\n%@",url,responseObject);
                                                 
                                                 
                                             } failure:^(NSString *stateCode, STError *error,NSError *originError) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 if (handle) {
                                                     handle(YES,@"",nil);
                                                 }
                                                 DDLogError(@"\n请求失败:\nurl:%@\nparam:%@\n失败原因:%@\n错误码:%ld",
                                                            url,paramDic,error.desc,error.code);
                                             }];
}
//查询详情
+ (void)sendOrderDetailRequestWithOrder_id:(NSString*)order_id  handle:(OEOrderDataNormalHandle)handle{
    NSMutableDictionary * paramDic = [NSMutableDictionary new];
    NSString * token = STUserManger.defult.loginedUser.token;
    if (token.length) {
        [paramDic setObject:token forKey:@"user_token"];
    }
    if (order_id.length) {
        [paramDic setObject:order_id forKey:@"order_id"];
    }
//    [paramDic setObject:NSBundle.st_UUID forKey:@"unique_id"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php?m=Front&c=User&a=orderView"];
    DDLogInfo(@"url:%@",url);
    DDLogInfo(@"param:%@",paramDic);
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:paramDic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 NSDictionary * modelDic = [responseObject valueForKey:@"content"];
                                                 if (handle) {
                                                     handle(YES,@"",modelDic);
                                                 }
                                                 // DDLogInfo(@"json = \n%@",modelDic.mj_JSONString);
                                                 DDLogInfo(@"%@请求成功:resp\n%@",url,responseObject);
                                                 
                                                 
                                             } failure:^(NSString *stateCode, STError *error,NSError *originError) {
                                                 //                                                 [SVProgressHUD dismiss];
                                                 if (handle) {
                                                     handle(YES,@"",nil);
                                                 }
                                                 DDLogError(@"\n请求失败:\nurl:%@\nparam:%@\n失败原因:%@\n错误码:%ld",
                                                            url,paramDic,error.desc,error.code);
                                             }];
}
@end
